package com.sbpm.crmbpm.server.dao.impl;

import com.sbpm.crmbpm.server.dao.DictionaryDao;
import com.sbpm.crmbpm.shared.data.dict.City;
import org.springframework.stereotype.Component;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

@Component
public class DictionaryDaoImpl implements DictionaryDao
{
    @PersistenceContext()
    private EntityManager em;

    @Override
    public List<City> getCitiesWithCountries()
    {
        String hql = "select c from City c join fetch c.country co";
        return em.createQuery( hql ).getResultList();
    }
}
